package com.groupnections.server.database.user;

import java.util.ArrayList;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

/**
 * List all the projects added in the system.
 */
public class ListUsers {

	public static List<com.groupnections.shared.entities.User> list(
			PersistenceManager persistenceManager, String group) {

		List<User> usersDatabase;

		Query query = persistenceManager.newQuery(User.class,
				"groups.contains(group)");

		query.declareParameters("String group");

		usersDatabase = (List<User>) query.execute(group);

		List<com.groupnections.shared.entities.User> users = new ArrayList<com.groupnections.shared.entities.User>();

		for (User databaseUser : usersDatabase) {

			users.add(ConvertDatabaseToUser.getUser(databaseUser));
		}

		return users;
	}
}
